<?php

/**
 * Is dir allowed to dir
 * 
 * @author Kozlov Denis
 * @version $Id$
 * @package Kpl
 *
 */
class Menu_Validator_Dir extends Menu_Validator_Abstract
{
	private function _getUserHelper() {
		return Zend_Controller_Action_HelperBroker::getStaticHelper("User");
	}
	
	private function _getStartDir() {
		if (!$this->_startdir) {
			$group = new Groups();
			$row =$group->fetchRow($group->select()->where("groupname = ?",$this->_getUserHelper()->getCurrentGroup()));
			
			$this->_startdir = $row->dirstart;
		}
		
		return $this->_startdir;
	}
	
	public function isValid($item)
	{

		if (in_array($item->dir, Array("","/","//"))) return true;
		
		if (($item->dir == "///") && ($item->name == $this->_getStartDir())) return true;

		if (strpos("t".$item->dir,$this->_getStartDir())) return true;
		
		return false;
	}

}
?>